//
// Created by guo on 24-8-30.
//

#ifndef BBDEMO_BBSERVER_H
#define BBDEMO_BBSERVER_H
#include <string>
#include <unordered_map>
#include "TCPServer.hpp"
#include "protocol.h"
#include "shared_locker.h"

class BBServer {
public:
    bool init(const std::string &ip, uint16_t port);
    void run();
    void handle_data();
    void parse_data(const std::string& data, std::vector<std::pair<BBMsg, std::string> >& vec_msg);
    void handle_msg(const std::string& session_name, std::vector<std::pair<BBMsg,std::string>>& vec_msg);
private:
    TCPServer* _server = nullptr;
    std::unordered_map<std::string,std::string> _bb_map;
    SharedLocker _shared_locker;
};

#endif //BBDEMO_BBSERVER_H
